from django.shortcuts import render

# Create your views here.
from rest_framework.generics import ListAPIView, RetrieveAPIView
from rest_framework_extensions.cache.mixins import ListCacheResponseMixin, RetrieveCacheResponseMixin

from areas.models import Area
from areas.serializers import AreaSerializer, SubAreaSerializer


class AreaView(ListCacheResponseMixin, ListAPIView):
    """查询所有的省份"""
    queryset = Area.objects.filter(parent_id=None)
    serializer_class = AreaSerializer

    pagination_class = None  # 禁用分页功能


class SubAreaView(RetrieveCacheResponseMixin, RetrieveAPIView):
    """查询城市或区县(查询一条区域数据)"""

    queryset = Area.objects.all()
    serializer_class = SubAreaSerializer




























